var setupTask;
var reviveCount = 5;
var mapIds = [220080300];
var 准备地图 = 220080000;
var eventName = "Boss_玩具城_闹钟王_困难";

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.setSpawn(false);
        d.killAllMonsters(true)
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(1000 * 60 * 30)
}

function onMonsterKilled(b, c) {
    if (c == 8500022) {
        b.startEventTimer(1000 * 30);
        for (var a = 0; a < b.getPlayerCount(); a++) {
            b.getPlayers().get(a).dropMessage(6, "副本挑战成功！已召唤击杀奖励！！")
        }
    }
    return 1
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
}

function Chuansong(b, a) {
    if (b.getMapInstance(993060800).getCharactersSize() != 0) {
        warp(b, 993060900, 0)
    } else {
        if (b.getMapInstance(993060900).getCharactersSize() != 0) {
            warp(b, 993061000, 0)
        } else {
            if (b.getMapInstance(993061000).getCharactersSize() != 0) {
                warp(b, 993060003, 0)
            }
        }
    }
}

function openNpc(c, b, d) {
    for (var a = 0; a < c.getPlayerCount(); a++) {
        c.getPlayers().get(a).getAPI().openNpc(b, d)
    }
}

function warp(d, c, a) {
    for (var b = 0; b < d.getPlayerCount(); b++) {
        d.getPlayers().get(b).getAPI().warp(c, a)
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onMonsterDamaged(b, a, d, e, c) {}

function onItemPickedUp() {};